function mobileloginSubmit(){
    //点击按钮后让其置灰不可点并出现动态小点点
    var loginValue = document.getElementById("indexLoginSubmit").value;		//先前按钮的值
    waitingStation("indexLoginSubmit",inlogin);

    var url = "/mobile/login.do?random="+Math.round(Math.random()*100);
    var uName = document.getElementById("indexLoginName").value;
    var pWord = document.getElementById("indexLoginPwd").value;
    if(uName == ""){
        document.getElementById("indexLoginTips").style.display="block";
        document.getElementById("indexLoginTips").innerHTML="";
        document.getElementById("indexLoginTips").innerHTML=coincommonjs10;
        //恢复按钮让其可点击并去掉小点点
        cancelWaiting("indexLoginSubmit",loginValue);
        return ;
    }
    if(! checkEmail(uName)&&uName.indexOf("@") > 0){
        document.getElementById("indexLoginTips").style.display="block";
        document.getElementById("indexLoginTips").innerHTML="";
        document.getElementById("indexLoginTips").innerHTML=coincommonjs9;
        //恢复按钮让其可点击并去掉小点点
        cancelWaiting("indexLoginSubmit",loginValue);
        return ;
    }
    if(pWord == ""){
        document.getElementById("indexLoginTips").style.display="block";
        document.getElementById("indexLoginTips").innerHTML="";
        document.getElementById("indexLoginTips").innerHTML=coincommonjs11;
        //恢复按钮让其可点击并去掉小点点
        cancelWaiting("indexLoginSubmit",loginValue);
        return ;
    }else if(pWord.length <6){
        document.getElementById("indexLoginTips").style.display="block";
        document.getElementById("indexLoginTips").innerHTML="";
        document.getElementById("indexLoginTips").innerHTML=coincommonjs12;
        //恢复按钮让其可点击并去掉小点点
        cancelWaiting("indexLoginSubmit",loginValue);
        return ;
    }
    var param={loginName:uName,password:pWord};
    jQuery.post(url,param,function(data){
        var result = eval('(' + data + ')');
        if(result!=null){
            if(result.resultCode == 0){
                if(document.getElementById("forwardUrl")!=null && document.getElementById("forwardUrl").value != ""){
                    var forward = document.getElementById("forwardUrl").value;
                    forward = decodeURI(forward);
                    if (checkURL(forward)){
                        window.location.href=forward;
                    }else{
                        window.location.href=document.getElementById("coinMainUrl").value;
                    }
                }else{
                    window.location.href=document.getElementById("coinMainUrl").value;
                }
            }else if(result.resultCode == -1){
                document.getElementById("indexLoginTips").style.display="block";
                document.getElementById("indexLoginTips").innerHTML="";
                document.getElementById("indexLoginTips").innerHTML="用户名或密码错误";
            }else if(result.resultCode == -2){
                document.getElementById("indexLoginTips").style.display="block";
                document.getElementById("indexLoginTips").innerHTML="";
                document.getElementById("indexLoginTips").innerHTML="此ip登录频繁，请2小时后再试";
            }else if(result.resultCode == -3){
                document.getElementById("indexLoginTips").style.display="block";
                document.getElementById("indexLoginTips").innerHTML="";
                if(result.errorNum == 0){
                    document.getElementById("indexLoginTips").innerHTML="此ip登录频繁，请2小时后再试";
                }else{
                    document.getElementById("indexLoginTips").innerHTML="用户名或密码错误，您还有"+result.errorNum+"次机会";
                }
                document.getElementById("indexLoginPwd").value="";
            }else if(result.resultCode == -4){
                document.getElementById("indexLoginTips").style.display="block";
                document.getElementById("indexLoginTips").innerHTML="";
                document.getElementById("indexLoginTips").innerHTML="您的浏览器还未开启COOKIE,请设置启用COOKIE功能";
            }else if(result.resultCode == 1){
                if(document.getElementById("forwardUrl") && document.getElementById("forwardUrl").value != ""){
                    var forward = document.getElementById("forwardUrl").value;
                    forward = decodeURI(forward);
                    if (checkURL(forward)){
                        window.location.href = document.getElementById("refUrl").value + "?forward=" + forward;
                    } else {
                        window.location.href = document.getElementById("refUrl").value;
                    }
                }else{
                    window.location.href = document.getElementById("refUrl").value;
                }
            }else if(result.resultCode == 2){
                document.getElementById("indexLoginTips").innerHTML="账户出现安全隐患已被冻结，请尽快联系客服处理";
            }

            if(result.resultCode != 0 && result.resultCode != 1){
                //恢复按钮让其可点击并去掉小点点
                cancelWaiting("indexLoginSubmit",loginValue);
            }
        }
    });

}

function mobileTotpCodeSubmit(){
    //点击按钮后让其置灰不可点并出现动态小点点
    var confirmValue = "";
    if(document.getElementById("googleTwiceLogin") != null){
        confirmValue = document.getElementById("googleTwiceLogin").value;		//先前按钮的值
        waitingStation("googleTwiceLogin",confirmValue);
    }
    var totpCode = "";
    if(document.getElementById("totpCodeDialog")) {
        totpCode = document.getElementById("totpCodeDialog").value;
    }else {
        totpCode = document.getElementById("totpCode").value;
    }
    var regu = /^[0-9]{6}$/;
    var re = new RegExp(regu);
    var errorSpan = document.getElementById("errorSpan");
    if(document.getElementById("errorSpanDialog")) {
        errorSpan = document.getElementById("errorSpanDialog");
    }
    if (!re.test(totpCode)) {
        errorSpan.style.display = "block";
        errorSpan.innerHTML = coincommonjs49;
        //恢复按钮让其可点击并去掉小点点
        cancelWaiting("googleTwiceLogin",confirmValue);
        return ;
    }
	var url = "/mobile/submitTotpCode.do?random="+Math.round(Math.random()*100);
	var param={totpCode:totpCode};
	jQuery.post(url,param,function(data){
        var result = eval('(' + data + ')');
        if(result!=null){
            if(result.resultCode == 0){
                if(document.getElementById("forwardUrl")!=null && document.getElementById("forwardUrl").value != ""){
                    var forward = document.getElementById("forwardUrl").value;
                    forward = decodeURI(forward);
                    if (checkURL(forward)){
                        window.location.href=forward;
                    }else{
                        window.location.href=document.getElementById("coinMainUrl").value;
                    }
                }else{
                    window.location.href=document.getElementById("coinMainUrl").value;
                }
            }else if(result.resultCode == -1){
                document.getElementById("errorSpan").style.display = "block";
                document.getElementById("errorSpan").innerHTML = "请正确输入谷歌验证码。";
                document.getElementById("totpCode").value = "";
            }else if(result.resultCode == -2){
                document.getElementById("errorSpan").style.display = "block";
                if(result.errorNum == 0){
                    document.getElementById("errorSpan").innerHTML="谷歌验证码错误多次，请2小时后再试";
                }else{
                    document.getElementById("errorSpan").innerHTML="谷歌验证码错误，您还有"+result.errorNum+"次机会";
                    document.getElementById("totpCode").value = "";
                }
            }else if(result.resultCode == -20){
                document.getElementById("errorSpan").style.display = "block";
                document.getElementById("errorSpan").innerHTML = "此谷歌验证码已使用,请稍后再试";
                document.getElementById("totpCode").value = "";
            }
            //恢复按钮让其可点击并去掉小点点
            if(result.resultCode != 0 && result.resultCode != 2){
                cancelWaiting("googleTwiceLogin",confirmValue);
            }
        }
	});
}

function regSubmitInMobile(){

    var regType = 0;// 注册方式：手机注册
    var phone = trim(document.getElementById("regPhoneNumber").value);

    var areaCode = -1;
    if(document.getElementById("areaCode")) {
        var areaCodeInput = document.getElementById("areaCode");
        areaCode = areaCodeInput.value;
    }
    var msgCodeInput = document.getElementById("validatePhoneCode");
    var msgCode = "";
    if(msgCodeInput){
        msgCode = trim(msgCodeInput.value);
    }

    //验证手机号
    var desc = "";
    if(phone.indexOf(" ")>-1){
        desc=coincommonjs21;
    }else {
        if(phone==''){
            desc=coincommonjs22;
        }else{
            if(areaCode==86){
                if(!checkMobile(phone)){
                    desc=coincommonjs23;
                }
            }else if(areaCode!=86){
                if(!checkPositiveNumber(phone)){
                    desc=coincommonjs23;
                }
            }
        }
    }
    if(areaCode<0 && desc==""){
        desc = get$("pleaseselectthecountrycode");
    }
    if((msgCode==null||msgCode=='') && desc==""){
        desc = get$("entersmscode");
    }else if(msgCode.length!=6 && desc==""){
        desc = get$("smscodeformatincorrect");
    }
    if(desc!=""){
        if(document.getElementById("regNameResult")!=null){
            document.getElementById("regNameResult").innerHTML=desc;
        }
        return false;
    }

    //点击按钮后让其置灰不可点并出现动态小点点
    var regeditValue = document.getElementById("regBtn").value;		//先前按钮的值
    waitingStation("regBtn",regeditValue);

    var url = "/mobile/registerByPhone.do?random="+Math.round(Math.random()*100);
    var param={regName:phone,regType:regType,areaCode:areaCode,msgCode:msgCode};
    jQuery.post(url,param,function(resultData){
        var result = null;
        var data = -100;
        if(resultData!=null){
            result = eval('(' + resultData + ')');
        }
        if(result!=null){
            data = result.resultCode;
        }

        if(data < 0){
            var desc = "";
            //注册失败
            if(data == -2){
                // 手机或邮箱已被占用
                if(regType == 0){
                    desc = coincommonjs30+"，"+coincommonjs31+"<a target='_blank' href='http://wpa.qq.com/msgrd?v=3&uin=2912851536&site=qq&menu=yes' title='联系客服'>"+coincommonjs33+"</a>";
                }else{
                    jQuery("#regNameResult").removeClass("success").addClass("error");
                    desc = coincommonjs34;
                }
            }else if(data == -1){
                if(regType == 0){
                    desc = get$("coincommonjs23");
                }else{
                    desc = get$("coincommonjs40");
                }
            }else if(data==-6){
                // 验证码错误
                desc = get$("userindexjs27");
            }else if(data == -5){
                desc = coincommonjs7;
            }else if(data == -7){
                // 短信验证码错误
                desc = get$("smscodeisincorrect")+" "+get$("youhave")+result.errorNum+chancesleft;
            }else if(data == -20){
                // 手机号码限制
                desc=smscodewrongmuchtime;
            }else if(data == -30){
                // 短信验证码错误次数限制
                desc=blindmoretime;
            }else{
                // 注册失败
                desc=get$("signupfailed");
            }
            if(document.getElementById("regNameResult")!=null){
                document.getElementById("regNameResult").innerHTML=desc;
            }
            //恢复按钮让其可点击并去掉小点点
            cancelWaiting("regBtn",regeditValue);
        }else{
            if(document.getElementById("forwardUrl")!=null && document.getElementById("forwardUrl").value != ""){
                var forward = document.getElementById("forwardUrl").value;

                if (jQuery(document.getElementById("forwardUrl")).attr('direct') == 'true') {
                    window.location.href=forward;
                    return;
                }

                forward = decodeURI(forward);
                if (checkURL(forward)) {
                    window.location.href=forward;
                } else {
                    window.location.href = document.getElementById("coinMainUrl").value+"/mobile/index.do";
                }

            }
            window.location.reload();
        }
    });
}